#!/usr/bin/env bash -e
SCRIPT_FILE=$(readlink -f $BASH_SOURCE)
SCRIPT_DIR=$(dirname $SCRIPT_FILE)

target="$SCRIPT_DIR/vscode-server-linux-x64.tar.gz"
if [ -f $target ] && [ -e $target ]; then
    echo "vscode-server-linux-x64.tar.gz already exists"
else
    COMMIT_HASH=$(code -v | sed -n '2p') && \
    wget "https://update.code.visualstudio.com/commit:${COMMIT_HASH}/server-linux-x64/stable" -O $target
fi